package seata.storage.service;

import io.seata.core.context.RootContext;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

@Slf4j
@Service
@RequiredArgsConstructor
public class StorageService {
	final JdbcTemplate jdbcTemplate;

	public void deduct(String commodityCode, int count) {
		log.info("Storage Service ... xid: " + RootContext.getXID());
		jdbcTemplate.update("update storage_tbl set count = count - ? where commodity_code = ?", count, commodityCode);
	}
}